package cn.dankal.flyaudio.home

import android.view.View
import android.view.ViewGroup
import cn.dankal.basiclib.base.recyclerview.BaseRecyclerViewAdapter
import cn.dankal.basiclib.base.recyclerview.BaseRecyclerViewHolder
import cn.dankal.basiclib.util.StringUtil
import cn.dankal.basiclib.util.TimeUtil.getFgtime
import cn.dankal.basiclib.util.image.PicUtils
import cn.dankal.business.Constants
import cn.dankal.business.pojo.ActivityBean
import cn.dankal.flyaudio.R
import kotlinx.android.synthetic.main.layout_tag_all.view.*
import kotlinx.android.synthetic.main.rv_item_activity.view.*
import com.bumptech.glide.Glide
import cn.dankal.flyaudio.R.id.imageView


class ActivityAdapter2 : BaseRecyclerViewAdapter<ActivityBean>() {
    override fun getLayoutResId(viewType: Int): Int {
        return R.layout.rv_item_activity2
    }

    override fun getViewHolder(parent: ViewGroup?, rootView: View?, viewType: Int): BaseRecyclerViewHolder<*> {
        return ViewHolder(rootView)
    }

    override fun onViewRecycled(holder: BaseRecyclerViewHolder<ActivityBean>) {
        super.onViewRecycled(holder)
        val imageView = holder.itemView.iv_img
        if (imageView != null) {
            Glide.with(context).clear(imageView)
        }
    }

    class ViewHolder(itemView: View?) : BaseRecyclerViewHolder<ActivityBean>(itemView) {
        override fun onBindData(data: ActivityBean?, position: Int) {
            data?.apply {
                PicUtils.loadNormal(context, cover, itemView.iv_img, R.mipmap.pic_banner_holder, R.mipmap.pic_banner_holder)
//                itemView.tv_title.text = title
//                if (!StringUtil.isValid(oneTag)) {
//                    itemView.ll_tag_1.visibility = View.GONE
//                } else {
//                    itemView.ll_tag_1.visibility = View.VISIBLE
//                    itemView.tv_tag1.setText(oneTag)
//                }
//
//                if (!StringUtil.isValid(twoTag)) {
//                    itemView.ll_tag_2.visibility = View.GONE
//                } else {
//                    itemView.ll_tag_2.visibility = View.VISIBLE
//                    itemView.tv_tag2.setText(twoTag)
//                }
//                if (!StringUtil.isValid(threeTag)) {
//                    itemView.ll_tag_3.visibility = View.GONE
//                } else {
//                    itemView.ll_tag_3.visibility = View.VISIBLE
//                    itemView.tv_tag3.setText(threeTag)
//                }
                itemView.tv_title.text = title
                itemView.tv_time.text = getFgtime(activitySite) + " / " + getFgtime(applyStartTime)
                //0未开始 1进行中 2已结束
//                itemView.iv_state.setImageResource(
//                        if (activityStatus == Constants.ActivityStatus.NoStart.statusCode) R.mipmap.pic_title_not else {
//                            if (activityStatus == Constants.ActivityStatus.OnProgress.statusCode) R.mipmap.pic_bg_2 else {
//                                R.mipmap.pic_title_ed
//                            }
//                        })
            }

        }
    }
}
